package sicnu.cs.ich.ich.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.context.WebApplicationContext;
import sicnu.cs.ich.token.security.config.BaseTokenSecurityConfig;
import sicnu.cs.ich.token.security.config.TokenSecurity;

/**
 * @author Lione
 */
//@Order(Ordered.HIGHEST_PRECEDENCE)
@Configuration
public class TokenSecurityConfig extends BaseTokenSecurityConfig {

    @Bean
    @Override
    @Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
    public TokenSecurity tokenSecurity() {
        return super.tokenSecurity()
                .antMatchers("/ichs/**").hasAny("ROLE_PERSON")
                .antMatchers("/admin/ichs/**").hasAny("ROLE_ADMIN")
                .anyRequest().authenticated();
    }
}
